/**
 * 
 */
package com.james.android.pingtu;

import com.james.android.utils.LogUtils;

import android.content.Intent;
import android.os.Bundle;
import android.preference.*;

/**
 * 游戏设置
 * @author Winter Lau
 */
public class MagicSetting extends PreferenceActivity {

	public final static int REQUEST_CODE_GAME_IMAGE = 0x10;
	
	private final static String KEY_BGSOUND = "bgsound";
	private final static String KEY_IMG = "game_pic";
	private final static String KEY_HABIT = "habits";
	
    private ImageOptionPreference imgOption;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        this.addPreferencesFromResource(R.xml.setting);
        //背景音乐设置
//        CheckBoxPreference mBgsound = (CheckBoxPreference)this.findPreference(KEY_BGSOUND);
//        mBgsound.setChecked(GameGlobal.is_audio_on());
//        mBgsound.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
//			@Override
//			public boolean onPreferenceChange(Preference preference, Object newValue) {
//				GameGlobal.set_audio((Boolean)newValue);
//				return true;
//			}
//		});
        //使用习惯设置
//        CheckBoxPreference mHabit = (CheckBoxPreference)this.findPreference(KEY_HABIT);
//        mHabit.setChecked(GameGlobal.is_left_hand());
//        mHabit.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
//			@Override
//			public boolean onPreferenceChange(Preference preference, Object newValue) {
//				GameGlobal.set_left_hand((Boolean)newValue);
//				return true;
//			}
//		});
        //图片设置
        this.imgOption = (ImageOptionPreference)this.findPreference(KEY_IMG);
        this.imgOption.setActivity(this);
	}

	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		LogUtils.debug("onActivityResult", "====================> %d", resultCode);
		switch(requestCode){
		case REQUEST_CODE_GAME_IMAGE:
			if(resultCode != 0)
				this.imgOption.ChangeGamePic(resultCode);			
		}		
	}
}
